package com.company.bookstore.controller.user_admin_module;


import com.company.bookstore.common.result.MvcResult;
import com.company.bookstore.entities.user_admin_module.Roles;
import com.company.bookstore.service.user_admin_module.RoleService;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 管理员角色表 前端控制器
 * </p>
 *
 * @author 吴经纶
 * @since 2020-08-28
 */

@RestController
@RequestMapping("/role")
public class RoleController {

    @Resource
    private RoleService roleService;


    @ApiOperation("获取角色列表接口")
    @GetMapping("/list")
    public MvcResult<Object> getList(){
        try {
            List<Roles> list = roleService.list();
            return MvcResult.builder().code(200).message("查询成功").object(list).build();
        }catch (Exception e) {
            return MvcResult.builder().message("获取角色列表失败，请稍后重试").code(500).build();
        }
    }
}
